package com.example.skytakeoutserver.repository

import com.example.skytakeoutserver.data.entity.Employee
import org.springframework.data.r2dbc.repository.Modifying
import org.springframework.data.r2dbc.repository.Query
import org.springframework.data.repository.reactive.ReactiveCrudRepository
import org.springframework.stereotype.Repository
import reactor.core.publisher.Mono
import java.time.Instant

@Repository
interface EmployeeRepository : ReactiveCrudRepository<Employee, Long> {
    fun findByUsername(name: String): Mono<Employee>

    @Modifying
    @Query("UPDATE employee SET status = :status,update_time = :updateTime  WHERE id = :id")
    fun updateStatusById(id: Long, status: Int, updateTime: Instant): Mono<Int>
}
